﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XQ.WeChatOfficialAccount.DAL;
using XQ.WeChatOfficialAccount.DAL.DAL;

namespace XQ.WeChatOfficialAccount.BLL.Sys
{
    public class AreaBLL
    {
        AreaDal areaDal = new AreaDal();

        /// <summary>
        /// 获取指定父节点的所有下级行政区划
        /// </summary>
        /// <param name="parentID"></param>
        /// <returns></returns>
        public List<Sys_Area> GetAreaList(long parentID)
        {
            return areaDal.FindAllModel(a => a.pid == parentID);
        }

        /// <summary>
        /// 根据身份证获取学生籍贯
        /// </summary>
        public long[] GetNativePlaceByIDNumber(string idNumber)
        {
            long[] nativePlace = new long[3];
            string provinceCode = idNumber.Substring(0, 2);
            string cityCode = idNumber.Substring(0, 4) + "00000000";
            string countyCode = idNumber.Substring(0, 6) + "000000";

            nativePlace[0] = long.Parse(provinceCode);
            nativePlace[1] = long.Parse(cityCode);
            nativePlace[2] = long.Parse(countyCode);

            return nativePlace;

        }
    }
}
